


<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>

		<script src="https://unpkg.com/vue@3/dist/vue.global.js"></script>
	</head>
	<body>
		<div id="app">
			{{message}}
		</div>
		
		<script>
			// 创建一个混入对象
			const myMixin = {
				// 钩子函数 (生命周期函数) 则以混入块执行  再执行组件中的
				created(){
					console.log("BBBBBBB creeated()方法被执行人了")
					this.test()
				},
				data(){
					return {
						name:"Tom"
					}
				}
			}
			
			var app = Vue.createApp({
				mixins: [myMixin],
				data() {
					return {
						"message": "Hello Vue!",
						"name":"jerry"				/* 如果有同名的,以组件中为准 */
					}
				},				
				methods:{
					test(){
						console.log("test()方法被执行了!")
						console.log(this.message);
						console.log(this.name);
					}
				},
				created(){
					console.log("AAAAAA creeated()方法被执行人了")
					this.test()
				},
			});
			var vm = app.mount("#app")
		</script>



	</body>
</html>